﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Web.BL;
using Web.Models;

namespace Web
{
    /// <summary>
    /// Summary description for WebService
    /// </summary>
    
    [WebService(Namespace = "http://localhost/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]

    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]

    public class WebService : System.Web.Services.WebService
    {
        Service s = new Service();

        /// <summary>
        /// Web service which returns a list containing all the mails not archived nor deleted between two dates.
        /// </summary>
        /// <param name="id">int id representing the user</param>
        /// <param name="from">from date</param>
        /// <param name="to">to date</param>
        /// <returns> List<MessageRepresentation> </returns>
        [WebMethod]
        public List<MessageRepresentation> GetMail(int id, DateTime from, DateTime to)
        {
            return s.GetMessageRepresentationsRecievedBy(id, from, to);
        }

        /// <summary>
        /// Web service which returns a list containing all the mails not archived nor deleted between two dates and
        /// if title, message or the receiver contain the search string (q).
        /// </summary>
        /// <param name="id">int id of the user</param>
        /// <param name="from">from date</param>
        /// <param name="to">to date</param>
        /// <param name="q">search string</param>
        /// <returns> List<MessageRepresentation> </returns>
        [WebMethod]
        public List<MessageRepresentation> GetMailContaining(int id, DateTime from, DateTime to, string q)
        {
            return s.GetMessageRepresentationsRecievedBy(id, from, to, q);
        }

    }
}
